iT邦幫忙

2024 iThome 鐵人賽

DAY 16
0
佛心分享-刷題不只是刷題

CPE C++ 刷題系列 第 16

CPE C++ 刷題 Day 16

  • 分享至 

  • xImage
  •  

今天來解YKL16(UVA272):TeX Quotes

TeX Quotes

https://ithelp.ithome.com.tw/upload/images/20240930/20155574QcELI22kmQ.png
https://ithelp.ithome.com.tw/upload/images/20240930/20155574ihqHN5mjpX.png

基數為 " => ``
偶數為 " => ''

#include <iostream>
#include <string>
using namespace std;

int main(){
	string str;
	int tmp=1;
	while(getline(cin,str)){
		
		for(int i=0;i<str.size();i++){
			if(str[i] == '"' && tmp%2 == 1){
				cout << "``";
				tmp+=1;
			}else if(str[i] == '"' && tmp%2 == 0){
				cout << "''";
				tmp+=1;
			}else{
				cout << str[i];
				
			}
		}
		cout << endl;
		
	}

	return 0;
}

上一篇
CPE C++ 刷題 Day 15
下一篇
CPE C++ 刷題 Day 17
系列文
CPE C++ 刷題20
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言